

  const fs = require('fs')
  const path = require('path')
  let filedata = ''

  fs.readFile(path.join(__dirname, './file/a.txt'), 'utf-8', (err, data) => {
    if(err) return console.log(err.message)
    filedata = data
    console.log(data)
    console.log('Read file successfully.')

    fs.writeFile(path.join(__dirname, './file/b.txt'), filedata, (err, data) => {
      if(err) return console.log('Failed to write to file' + err.message)
      console.log('Succeed to write file.')
    })
  })